# -*- coding:utf-8 -*-
# @Author: shenyuyu
# @Time: 2023/6/26 10:52
# @File: qu_3_reduce.py

from pyspark import SparkConf, SparkContext
from operator import add

if __name__ == '__main__':
    conf = SparkConf().setAppName("test").setMaster("local[*]")
    sc = SparkContext(conf=conf)

    rdd = sc.parallelize([1, 2, 3, 4, 5, 6])

    # rdd.reduce(lambda a, b: a + b)
    result = rdd.reduce(add)
    print(result)